package com.zhengtoudai.http;

import com.google.gson.JsonObject;
import com.zhengtoudai.ui.bean.AccountSettingModel;
import com.zhengtoudai.ui.bean.BorrowDetails;
import com.zhengtoudai.ui.bean.BorrowModel;
import com.zhengtoudai.ui.bean.DelegationNominis;
import com.zhengtoudai.ui.bean.Index;
import com.zhengtoudai.ui.bean.Login;
import com.zhengtoudai.ui.bean.MessageCenterModel;
import com.zhengtoudai.ui.bean.MyFragmentModel;
import com.zhengtoudai.ui.bean.MyInvestment;
import com.zhengtoudai.ui.bean.MyInvestmentMoldel;
import com.zhengtoudai.ui.bean.MyRedpacketModel;
import com.zhengtoudai.ui.bean.OnlyFinish;
import com.zhengtoudai.ui.bean.RedeemTransfer;
import com.zhengtoudai.ui.bean.Repossessed;
import com.zhengtoudai.ui.bean.Result;
import com.zhengtoudai.ui.bean.ShareRecordModel;
import com.zhengtoudai.ui.bean.ShengTenpay;
import com.zhengtoudai.ui.bean.TenderRecord;
import com.zhengtoudai.ui.bean.TransferDetail;
import com.zhengtoudai.ui.bean.TransferModel;

import java.util.Map;

import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Url;
import rx.Observable;

/**
 *
 */
public interface HttpService {

    @GET("appIndexCorrelation/indexborrow.app")
    Observable<Result<Index>> getIndexBorrow();

    @FormUrlEncoded
    @POST("appUserCorrelation/getSMSVerifyCodeOfMobile.app")
    Observable<Result> getSMSCode(@Field("mobile") String mobile);

    @FormUrlEncoded
    @POST("appUserCorrelation/register.app")
    Observable<Result> register(@FieldMap Map<String,String> params);

    @FormUrlEncoded
    @POST("appUserCorrelation/login.app")
    Observable<Result<Login>> login(
            @Field("userAccount") String userAccount
            ,@Field("userPassword") String userPassword);

    @GET("appAccountCorrelation/exit.app")
    Observable<Result> loginOut();

    @FormUrlEncoded
    @POST("appUserCorrelation/resetPassword.app")
    Observable<Result> forgerPassword(
            @Field("userPhone") String userPhone,
            @Field("userPassword") String userPassword,
            @Field("enterPassword2") String enterPassword2,
            @Field("verify") String verify);

    //账户中心数据 不需要请求参数
    @GET("appAccountCorrelation/accountIndex.app")
    Observable<MyFragmentModel>  getAccountIndex();


    //设置中心 不需要参数
    @GET("appAccountCorrelation/setCenter.app")
    Observable<AccountSettingModel> getAccountSetting();

    //无参数托管请求
    @GET
    Observable<ShengTenpay> getShengTenpay(@Url String url);

    //带参数托管请求
    @FormUrlEncoded
    @POST
    Observable<ShengTenpay> postShengTenpay(@Url String url,@FieldMap Map<String,String> params);
    /**
     * 消息中心 需要参数
     * @param umPerPage 每页多少记录数
     * @param pageNum 当前第几页
     */
    @FormUrlEncoded
    @POST("appAccountCorrelation/myMessages.app")
    Observable<MessageCenterModel> getMessage(
            @Field("umPerPage") String umPerPage
            ,@Field("pageNum") String pageNum);

    @FormUrlEncoded
    @POST("appAccountCorrelation/updatePassword.app")
    Observable<Result> changePassword(
            @Field("oldPassword")String oldPassword,
            @Field("newPassword")String newPassword,
            @Field("enterPassword")String enterPassword);
    /**
     * 我的红包 需要参数
     * @param umPerPage 每页多少记录数
     * @param pageNum 当前第几页
     */
    @FormUrlEncoded
    @POST("appAccountCorrelation/myRedenvelope.app")
    Observable<MyRedpacketModel> getMyRedpacket(
            @Field("numPerPage") String umPerPage
            ,@Field("pageNum") String pageNum);

    /**
     * 我的投资 需要参数
     * @param umPerPage 每页多少记录数
     * @param pageNum 当前第几页
     */
    @FormUrlEncoded
    @POST("appAccounCorrelation/borrowTransfer.app")
    Observable<MyInvestmentMoldel> getMyInvestment(
            @Field("numPerPage") String umPerPage
            ,@Field("pageNum") String pageNum);


    /**
     * 邀请记录 需要参数
     * @param umPerPage 每页多少记录数
     * @param pageNum 当前第几页
     */
    @FormUrlEncoded
    @POST("appAccountCorrelation/recommendList.app")
    Observable<ShareRecordModel> getShareRecord(
            @Field("numPerPage") String umPerPage
            ,@Field("pageNum") String pageNum);

    /**
     * 债权转让
     * @param numPerPage
     * @param pageNum
     * @return
     */
    @FormUrlEncoded
    @POST("appAccountCorrelation/borrowTransfer.app")
    Observable<DelegationNominis> borrowTransfer(@Field("numPerPage") String numPerPage,
                                                 @Field("pageNum") String pageNum);
    @FormUrlEncoded
    @POST("appAccountCorrelation/accountLog.app")
    Observable<JsonObject> accountLog(@FieldMap Map<String,String> params);




    /**
     * 政信列表 暂时不需要参数
     *
     */
    @FormUrlEncoded
    @POST("appBorrowCorrelation/borrowList.app")
    Observable<BorrowModel> getGetBorrowList(@FieldMap Map<String,String> params);


    /**
     * 债权转让的列表
     * */
    @FormUrlEncoded
    @POST("appBorrowCorrelation/appTransferList.app")
    Observable<TransferModel> getGetTransferList(@FieldMap Map<String,String> params);


    @GET("appAccountCorrelation/redeemTransfer/{etenderId}.app")
    Observable<RedeemTransfer> redeemTransfer(@Path("etenderId") String etenderId);

    @FormUrlEncoded
    @POST("appAccountCorrelation/requestTransfer.app")
    Observable<Result> requestTransfer(@Field("transferMoney") String transferMoney,
                                       @Field("etenderId") String etenderId,
                                       @Field("endTimeStr") String endTimeStr);

    //债权转让详情
    @FormUrlEncoded
    @POST("appBorrowLoggedCorrelation/showBorrowTransfer.app")
    Observable<Result<TransferDetail>> TransferDetail(@Field("borrowTransId") String borrowTransId);

    //项目详情
    @GET("appBorrowLoggedCorrelation/borrowDetail/{borrowEId}.app")
    Observable<Result<BorrowDetails>> borrowDetail(@Path("borrowEId") String borrowEId);

    //投标记录
    @FormUrlEncoded
    @POST("appBorrowLoggedCorrelation/getTenderList.app")
    Observable<Result<TenderRecord>> tenderRecord(@Field("borrowEId") String borrowId);

    //认购记录
    @GET("appBorrowLoggedCorrelation/getTransferAuctionById/{transferEId}.app")
    Observable<Result<TenderRecord>> offerToBuyRecord(@Path("transferEId") String transferEId);

    @FormUrlEncoded
    @POST("appAccountCorrelation/myInvest.app")
    Observable<Result<MyInvestment>> myInvest(@Field("numPerPage") String numPerPage,
                                              @Field("pageNum") String pageNum);

    @FormUrlEncoded
    @POST("appAccountCorrelation/getRepossessedList.app")
    Observable<Result<Repossessed>> getRepossessed(@Field("numPerPage") String numPerPage,
                                                   @Field("pageNum") String pageNum);

    @FormUrlEncoded
    @POST("appAccountCorrelation/getOnlyFinishList.app")
    Observable<Result<OnlyFinish>> getOnlyFinish(@Field("numPerPage") String numPerPage,
                                                 @Field("pageNum") String pageNum);
}
